package com.cdshop.mvc;

import java.util.List;

import javax.servlet.jsp.PageContext;

import com.cdshop.comm.BusinessException;
import com.cdshop.dao.GoodsDAO;
import com.cdshop.entity.Goods;

public class ListPM extends AbstractPM {

	private static final long serialVersionUID = 1L;

	private List<Goods> goods;

	public List<Goods> getGoods() {
		return goods;
	}

	public void setGoods(List<Goods> goods) {
		this.goods = goods;
	}

	@SuppressWarnings("unchecked")
	@Override
	public void populate(PageContext pctx) throws BusinessException {
		goods = (List<Goods>) pctx.getRequest().getAttribute("ListPM.goods");
		if (goods == null) {
			goods = GoodsDAO.instance().list();
			pctx.getRequest().setAttribute("ListPM.goods", goods);
		}
	}
}
